#include<bits/stdc++.h>
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define mid ((l+r)>>1)
#define File(xxx) freopen(xxx".in","r",stdin),freopen(xxx".out","w",stdout)
using namespace std;
const int N=5e4+5,M=1e3+5;
int n,m;
char s[N],t[M];
int b[M];
int to[M][26],f[2][M];
signed main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	File("neck");
	cin>>s+1;n=strlen(s+1);
	cin>>t+1;m=strlen(t+1);
	for(int i=2,j=0;i<=m;i++){
		while(j>0&&t[j+1]!=t[i])
			j=b[j];
		if(t[j+1]==t[i])j++;
		b[i]=j;
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<26;j++){
			if(t[i+1]-'a'==j)to[i][j]=i+1;
			else to[i][j]=to[b[i]][j];
		}
	}
	memset(f,-0x3f,sizeof f);
	f[0][0]=0;
	for(int i=1;i<=n;i++){
		memset(f[1],-0x3f,sizeof f[1]);
		for(int j=0;j<m;j++){
			f[1][j]=max(f[1][j],f[0][j]);
			f[1][to[j][s[i]-'a']]=max(f[1][to[j][s[i]-'a']],f[0][j]+1);
		}
		swap(f[0],f[1]);
	}
	int ans=0;
	for(int i=0;i<m;i++)
		ans=max(ans,f[0][i]);
	cout<<ans;
	return 0;
}
